//! \file Abilities.cpp
//! \brief TODO: Document
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------

#include "Abilities.h"
#include "DiceExtensions.h"
#include "Core.h"

namespace DnD {

// =====[ Static Members ]======================================================


// =============================================================================
// Abilities::Abilities
// -----------------------------------------------------------------------------
//! The class constructor.
// -----------------------------------------------------------------------------
Abilities::Abilities()
{
  // Initialize all attributes to 0.
  m_Str = m_Dex = m_Con = m_Int = m_Wis = m_Cha = 0;
}


// =============================================================================
// Abilities::Abilities
// -----------------------------------------------------------------------------
//! The class constructor.
//!
//! \param [in] Arg
//!   TODO: document
// -----------------------------------------------------------------------------
Abilities::Abilities(int Str, int Dex, int Con, int Int, int Wis, int Cha)
{
  // Initialize each of the attributes as requested.
  m_Str = Str;
  m_Dex = Dex;
  m_Con = Con;
  m_Int = Int;
  m_Wis = Wis;
  m_Cha = Cha;
}


// =============================================================================
// Abilities::~Abilities
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
Abilities::~Abilities()
{
  // TODO Auto-generated destructor stub
}


// =============================================================================
// FxName
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
Abilities Abilities::operator+(Abilities Value)
{
  Abilities Result;

  // Add the abilities.
  Result.m_Str = m_Str + Value.m_Str;
  Result.m_Dex = m_Dex + Value.m_Dex;
  Result.m_Con = m_Con + Value.m_Con;
  Result.m_Int = m_Int + Value.m_Int;
  Result.m_Wis = m_Wis + Value.m_Wis;
  Result.m_Cha = m_Cha + Value.m_Cha;

  // Return the results.
  return (Result);
}


// =============================================================================
// FxName
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
Abilities Abilities::operator-(Abilities Value)
{
  Abilities Result;

  // Subtract the abilities.
  Result.m_Str = m_Str - Value.m_Str;
  Result.m_Dex = m_Dex - Value.m_Dex;
  Result.m_Con = m_Con - Value.m_Con;
  Result.m_Int = m_Int - Value.m_Int;
  Result.m_Wis = m_Wis - Value.m_Wis;
  Result.m_Cha = m_Cha - Value.m_Cha;

  // Return the results.
  return (Result);
}


// =============================================================================
// FxName
// -----------------------------------------------------------------------------
//! TODO: document
//!
//! \param [in] Arg
//!   TODO: document
//!
//! \retval Exception
//!   The success status of the requested operation.
//!   - eOKAY: Execution occurred as requested.
//!   .
//!
//! \b Example: \code
//! FxName(0);
//! \endcode
// -----------------------------------------------------------------------------
int Abilities::getStr()
{
  return (m_Str);
}


// TODO: comment
int Abilities::getDex()
{
  return (m_Dex);
}


// TODO: comment
int Abilities::getCon()
{
  return (m_Con);
}


// TODO: comment
int Abilities::getInt()
{
  return (m_Int);
}


// TODO: comment
int Abilities::getWis()
{
  return (m_Wis);
}


// TODO: comment
int Abilities::getCha()
{
  return (m_Cha);
}


std::string Abilities::getStrText()
{
  return (Core::IntToStr(m_Str));
}

std::string Abilities::getDexText()
{
  return (Core::IntToStr(m_Dex));
}


std::string Abilities::getConText()
{
  return (Core::IntToStr(m_Con));
}


std::string Abilities::getIntText()
{
  return (Core::IntToStr(m_Int));
}


std::string Abilities::getWisText()
{
  return (Core::IntToStr(m_Wis));
}


std::string Abilities::getChaText()
{
  return (Core::IntToStr(m_Cha));
}


// TODO: comment

//  Each ability score is produced by rolling 4d6 but discarding the lowest
// die value. TODO: write this better.
void Abilities::rollNew(void)
{
  // Roll new ability values.
  m_Str = rollDiscardLowest("1d6", 1);
  m_Dex = rollDiscardLowest("1d6", 1);
  m_Con = rollDiscardLowest("1d6", 1);
  m_Int = rollDiscardLowest("1d6", 1);
  m_Wis = rollDiscardLowest("1d6", 1);
  m_Cha = rollDiscardLowest("1d6", 1);
}


} // namespace DnD
